<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   Storm实时计算：流操作入门编程实践  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/16209.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466459572: Accept with keywords: (title(0.166666666667):流,社区,入门,编程,数盟,计算, topn(0.266666666667):社区,定义,数盟,行业资讯,数据挖掘,实际,入门,比较简单,数据源,参数,计算,文章,类型,基础架构,方法,类型信息,编程,Hadoop,空格,组件,实例,字符串,声明,逻辑,方式,数据,代码,单词,集群,消息).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    Storm实时计算：流操作入门编程实践
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    Storm实时计算：流操作入门编程实践 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,66] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/16209.html">
          Storm实时计算：流操作入门编程实践
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          1,407 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech" rel="category tag">
          文章
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        Storm是一个分布式是实时计算系统，它设计了一种对流和计算的抽象，概念比较简单，实际编程开发起来相对容易。下面，简单介绍编程实践过程中需要理解的Storm中的几个概念：
       </p>
       <ul>
        <li>
         Topology
        </li>
       </ul>
       <p>
        Storm中Topology的概念类似于Hadoop中的MapReduce Job，是一个用来编排、容纳一组计算逻辑组件（Spout、Bolt）的对象（Hadoop MapReduce中一个Job包含一组Map Task、Reduce Task），这一组计算组件可以按照DAG图的方式编排起来（通过选择Stream Groupings来控制数据流分发流向），从而组合成一个计算逻辑更加负责的对象，那就是Topology。一个Topology运行以后就不能停止，它会无限地运行下去，除非手动干预（显式执行bin/storm kill ）或意外故障（如停机、整个Storm集群挂掉）让它终止。
       </p>
       <ul>
        <li>
         Spout
        </li>
       </ul>
       <p>
        Storm中Spout是一个Topology的消息生产的源头，Spout应该是一个持续不断生产消息的组件，例如，它可以是一个Socket Server在监听外部Client连接并发送消息，可以是一个消息队列（MQ）的消费者、可以是用来接收Flume Agent的Sink所发送消息的服务，等等。Spout生产的消息在Storm中被抽象为Tuple，在整个Topology的多个计算组件之间都是根据需要抽象构建的Tuple消息来进行连接，从而形成流。
       </p>
       <ul>
        <li>
         Bolt
        </li>
       </ul>
       <p>
        Storm中消息的处理逻辑被封装到Bolt组件中，任何处理逻辑都可以在Bolt里面执行，处理过程和普通计算应用程序没什么区别，只是需要根据Storm的计算语义来合理设置一下组件之间消息流的声明、分发、连接即可。Bolt可以接收来自一个或多个Spout的Tuple消息，也可以来自多个其它Bolt的Tuple消息，也可能是Spout和其它Bolt组合发送的Tuple消息。
       </p>
       <ul>
        <li>
         Stream Grouping
        </li>
       </ul>
       <p>
        Storm中用来定义各个计算组件（Spout、Bolt）之间流的连接、分组、分发关系。Storm定义了如下7种分发策略：Shuffle Grouping（随机分组）、Fields Grouping（按字段分组）、All Grouping（广播分组）、Global Grouping（全局分组）、Non Grouping（不分组）、Direct Grouping（直接分组）、Local or Shuffle Grouping（本地/随机分组），各种策略的具体含义可以参考Storm官方文档、比较容易理解。
       </p>
       <p>
        下面，作为入门实践，我们简单介绍几种开发中常用的流操作处理方式的实现：
       </p>
       <p>
        <strong>
         Storm组件简单串行
        </strong>
       </p>
       <p>
        这种方式是最简单最直观的，只要我们将Storm的组件（Spout、Bolt）串行起来即可实现，只需要了解编写这些组件的基本方法即可。在实际应用中，如果我们需要从某一个数据源连续地接收消息，然后顺序地处理每一个请求，就可以使用这种串行方式来处理。如果说处理单元的逻辑非常复杂，那么就需要处理逻辑进行分离，属于同一类操作的逻辑封装到一个处理组件中，做到各个组件之间弱耦合（除了定义Field的schema外，只通过发送消息来连接各个组件）。
        <br/>
        下面，我实现一个简单的WordCount的例子，各个组件之间的连接方式，如下图所示：
        <br/>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/wordcount-topology.png"/>
        <br/>
        ProduceRecordSpout类是一个Spout组件，用来产生消息，我们这里模拟发送一些英文句子，实际应用中可以指定任何数据源，如数据库、消息中间件、Socket连接、RPC调用等等。ProduceRecordSpout类代码如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_24926">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               ProduceRecordSpout
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichSpout {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(ProduceRecordSpout.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               SpoutOutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               Random random;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               String[] records;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="plain">
               ProduceRecordSpout(String[] records) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .records = records;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               random =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Random();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               nextTuple() {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Utils.sleep(
              </code>
              <code class="value">
               500
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String record = records[random.nextInt(records.length)];
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               List&lt;Object&gt; values =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Values(record);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.emit(values, values);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "Record emitted: record="
              </code>
              <code class="plain">
               + record);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declare(
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "record"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        构造一个ProduceRecordSpout对象时，传入一个字符串数组，然后随机地选择其中一个句子，emit到下游（Downstream）的WordSplitterBolt组件，只声明了一个Field，WordSplitterBolt组件可以根据声明的Field，接收到emit的消息，WordSplitterBolt类代码实现如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_718435">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               WordSplitterBolt
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichBolt {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(WordSplitterBolt.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               OutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               prepare(Map stormConf, TopologyContext context,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               OutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               execute(Tuple input) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String record = input.getString(
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               if
              </code>
              <code class="plain">
               (record !=
              </code>
              <code class="keyword">
               null
              </code>
              <code class="plain">
               &amp;&amp; !record.trim().isEmpty()) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               for
              </code>
              <code class="plain">
               (String word : record.split(
              </code>
              <code class="string">
               "\\s+"
              </code>
              <code class="plain">
               )) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.emit(input,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Values(word,
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "Emitted: word="
              </code>
              <code class="plain">
               + word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.ack(input);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declare(
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "count"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        在execute方法中，传入的参数是一个Tuple，该Tuple就包含了上游（Upstream）组件ProduceRecordSpout所emit的数据，直接取出数据进行处理。上面代码中，我们将取出的数据，按照空格进行的split，得到一个一个的单词，然后在emit到下一个组件，声明的输出schema为2个Field：word和count，当然这里面count的值都为1。
        <br/>
        进行统计词频的组件为WordCounterBolt，实现代码如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_464223">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               WordCounterBolt
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichBolt {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(WordCounterBolt.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               OutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Map&lt;String, AtomicInteger&gt; counterMap = Maps.newHashMap();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               prepare(Map stormConf, TopologyContext context,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               OutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               execute(Tuple input) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String word = input.getString(
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               int
              </code>
              <code class="plain">
               count = input.getIntegerByField(
              </code>
              <code class="string">
               "count"
              </code>
              <code class="plain">
               );
              </code>
              <code class="comments">
               // 通过Field名称取出对应字段的数据
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               AtomicInteger ai = counterMap.get(word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               if
              </code>
              <code class="plain">
               (ai ==
              </code>
              <code class="keyword">
               null
              </code>
              <code class="plain">
               ) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               ai =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               AtomicInteger(
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               counterMap.put(word, ai);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               ai.addAndGet(count);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "DEBUG: word="
              </code>
              <code class="plain">
               + word +
              </code>
              <code class="string">
               ", count="
              </code>
              <code class="plain">
               + ai.get());
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.ack(input);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               33
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               cleanup() {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               34
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // print count results
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               35
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "Word count results:"
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               36
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               for
              </code>
              <code class="plain">
               (Entry&lt;String, AtomicInteger&gt; entry : counterMap.entrySet()) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               37
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "\tword="
              </code>
              <code class="plain">
               + entry.getKey() +
              </code>
              <code class="string">
               ", count="
              </code>
              <code class="plain">
               + entry.getValue().get());
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               38
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               39
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               40
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               41
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        上面代码通过一个Map来对每个单词出现的频率进行累加计数，比较简单。因为该组件是Topology的最后一个组件，所以不需要在declareOutputFields方法中声明Field的Schema，而是在cleanup方法中输出最终的结果，只有在该组件结束任务退出时才会调用cleanup方法输出。
        <br/>
        最后，需要基于上面的3个组件来创建一个Topology实例，提交到Storm集群去运行，配置代码如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_259860">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               main(String[] args)
              </code>
              <code class="keyword">
               throws
              </code>
              <code class="plain">
               AlreadyAliveException, InvalidTopologyException, InterruptedException {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // configure &amp; build topology
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               TopologyBuilder builder =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               TopologyBuilder();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String[] records =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               String[] {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               "A Storm cluster is superficially similar to a Hadoop cluster"
              </code>
              <code class="plain">
               ,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               "All coordination between Nimbus and the Supervisors is done through a Zookeeper cluster"
              </code>
              <code class="plain">
               ,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               "The core abstraction in Storm is the stream"
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               };
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .setSpout(
              </code>
              <code class="string">
               "spout-producer"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               ProduceRecordSpout(records),
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .setNumTasks(
              </code>
              <code class="value">
               3
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .setBolt(
              </code>
              <code class="string">
               "bolt-splitter"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               WordSplitterBolt(),
              </code>
              <code class="value">
               2
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "spout-producer"
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .setNumTasks(
              </code>
              <code class="value">
               2
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setBolt(
              </code>
              <code class="string">
               "bolt-counter"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               WordCounterBolt(),
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .fieldsGrouping(
              </code>
              <code class="string">
               "bolt-splitter"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ))
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .setNumTasks(
              </code>
              <code class="value">
               2
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // submit topology
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Config conf =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Config();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String name = WordCountTopology.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               .getSimpleName();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               if
              </code>
              <code class="plain">
               (args !=
              </code>
              <code class="keyword">
               null
              </code>
              <code class="plain">
               &amp;&amp; args.length &gt;
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               ) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String nimbus = args[
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               ];
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               conf.put(Config.NIMBUS_HOST, nimbus);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               conf.setNumWorkers(
              </code>
              <code class="value">
               2
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               StormSubmitter.submitTopologyWithProgressBar(name, conf, builder.createTopology());
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
              <code class="keyword">
               else
              </code>
              <code class="plain">
               {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LocalCluster cluster =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               LocalCluster();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               cluster.submitTopology(name, conf, builder.createTopology());
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Thread.sleep(
              </code>
              <code class="value">
               60000
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               cluster.shutdown();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               33
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               34
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        上面通过TopologyBuilder来配置组成一个Topology的多个组件（Spout或Bolt），然后通过调用createTopology()方法创建一个Topology实例。上面方法中，对应着2种运行模式：如果没有传递任何参数，则是使用LocalCluster来运行，适合本地调试代码；如果传递一个Topology名称作为参数，则是在真实的Storm集群上运行，需要对实现的Topology代码进行编译打包，通过StormSubmitter提交到集群上作为服务运行。
       </p>
       <p>
        <strong>
         Storm组合多种流操作
        </strong>
       </p>
       <p>
        Storm支持流聚合操作，将多个组件emit的数据，汇聚到同一个处理组件来统一处理，可以实现对多个Spout组件通过流聚合到一个Bolt组件（Sout到Bolt的多对一、多对多操作），也可以实现对多个Bolt通过流聚合到另一个Bolt组件（Bolt到Bolt的多对一、多对多操作）。实际，这里面有两种主要的操作，一种是类似工作流中的fork，另一种是类似工作流中的join。下面，我们实现一个例子来演示如何使用，实时流处理逻辑如下图所示：
        <br/>
        <img src="http://dataunion.org/wp-content/uploads/2015/04/multiple-streams-topology.png"/>
        <br/>
        上图所描述的实时流处理流程，我们期望能够按照如下流程进行处理：
       </p>
       <ul>
        <li>
         存在3类数据：数字字符串（NUM）、字母字符串（STR）、特殊符号字符串（SIG）
        </li>
        <li>
         每个ProduceRecordSpout负责处理上面提到的3类数据
        </li>
        <li>
         所有数据都是字符串，字符串中含有空格，3种类型的ProduceRecordSpout所emit的数据都需要被相同的逻辑处理：根据空格来拆分字符串
        </li>
        <li>
         一个用来分发单词的组件DistributeWordByTypeBolt能够接收到所有的单词（包含类型信息），统一将每类单词分别分发到指定的一个用来存储数据的组件
        </li>
        <li>
         SaveDataBolt用来存储处理过的单词，对于不同类型单词具有不同的存储逻辑，需要设置3类SaveDataBolt
        </li>
       </ul>
       <p>
        将Spout分为3类，每一个Spout发射不同类型的字符串，这里定义了一个Type常量类来区分这三种类型：
       </p>
       <div class="syntaxhighlighter " id="highlighter_761748">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               1
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               interface
              </code>
              <code class="plain">
               Type {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               2
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String NUMBER =
              </code>
              <code class="string">
               "NUMBER"
              </code>
              <code class="plain">
               ;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               3
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String STRING =
              </code>
              <code class="string">
               "STRING"
              </code>
              <code class="plain">
               ;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               4
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String SIGN =
              </code>
              <code class="string">
               "SIGN"
              </code>
              <code class="plain">
               ;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               5
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        首先看一下，我们实现的Topology是如何进行创建的，代码如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_790934">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               main(String[] args)
              </code>
              <code class="keyword">
               throws
              </code>
              <code class="plain">
               AlreadyAliveException, InvalidTopologyException, InterruptedException {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // configure &amp; build topology
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               TopologyBuilder builder =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               TopologyBuilder();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // configure 3 spouts
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setSpout(
              </code>
              <code class="string">
               "spout-number"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               ProduceRecordSpout(Type.NUMBER,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               String[] {
              </code>
              <code class="string">
               "111 222 333"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "80966 31"
              </code>
              <code class="plain">
               }),
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setSpout(
              </code>
              <code class="string">
               "spout-string"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               ProduceRecordSpout(Type.STRING,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               String[] {
              </code>
              <code class="string">
               "abc ddd fasko"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "hello the word"
              </code>
              <code class="plain">
               }),
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setSpout(
              </code>
              <code class="string">
               "spout-sign"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               ProduceRecordSpout(Type.SIGN,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               String[] {
              </code>
              <code class="string">
               "++ -*% *** @@"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "{+-} ^#######"
              </code>
              <code class="plain">
               }),
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // configure splitter bolt
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setBolt(
              </code>
              <code class="string">
               "bolt-splitter"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               SplitRecordBolt(),
              </code>
              <code class="value">
               2
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "spout-number"
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "spout-string"
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "spout-sign"
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // configure distributor bolt
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setBolt(
              </code>
              <code class="string">
               "bolt-distributor"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               DistributeWordByTypeBolt(),
              </code>
              <code class="value">
               6
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .fieldsGrouping(
              </code>
              <code class="string">
               "bolt-splitter"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // configure 3 saver bolts
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setBolt(
              </code>
              <code class="string">
               "bolt-number-saver"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               SaveDataBolt(Type.NUMBER),
              </code>
              <code class="value">
               3
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "bolt-distributor"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "stream-number-saver"
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setBolt(
              </code>
              <code class="string">
               "bolt-string-saver"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               SaveDataBolt(Type.STRING),
              </code>
              <code class="value">
               3
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "bolt-distributor"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "stream-string-saver"
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               builder.setBolt(
              </code>
              <code class="string">
               "bolt-sign-saver"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               SaveDataBolt(Type.SIGN),
              </code>
              <code class="value">
               3
              </code>
              <code class="plain">
               )
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               .shuffleGrouping(
              </code>
              <code class="string">
               "bolt-distributor"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "stream-sign-saver"
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // submit topology
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Config conf =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Config();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String name = MultiStreamsWordDistributionTopology.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               .getSimpleName();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               if
              </code>
              <code class="plain">
               (args !=
              </code>
              <code class="keyword">
               null
              </code>
              <code class="plain">
               &amp;&amp; args.length &gt;
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               ) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               33
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String nimbus = args[
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               ];
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               34
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               conf.put(Config.NIMBUS_HOST, nimbus);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               35
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               conf.setNumWorkers(
              </code>
              <code class="value">
               3
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               36
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               StormSubmitter.submitTopologyWithProgressBar(name, conf, builder.createTopology());
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               37
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
              <code class="keyword">
               else
              </code>
              <code class="plain">
               {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               38
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LocalCluster cluster =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               LocalCluster();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               39
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               cluster.submitTopology(name, conf, builder.createTopology());
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               40
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Thread.sleep(
              </code>
              <code class="value">
               60
              </code>
              <code class="plain">
               *
              </code>
              <code class="value">
               60
              </code>
              <code class="plain">
               *
              </code>
              <code class="value">
               1000
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               41
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               cluster.shutdown();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               42
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               43
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        一个SplitRecordBolt组件从3个不同类型的ProduceRecordSpout接收数据，这是一个多Spout流聚合。SplitRecordBolt将处理后的数据发送给DistributeWordByTypeBolt组件，然后根据收到的数据的类型进行一个分发处理，这里用了fieldsGrouping操作，也就是SplitRecordBolt发送的数据会按照类型发送到不同的DistributeWordByTypeBolt任务（Task），每个Task收到的一定是同一个类型的数据，如果直接使用shuffleGrouping操作也没有问题，只不过每个Task可能收到任何类型的数据，在DistributeWordByTypeBolt内部进行流向控制。DistributeWordByTypeBolt组件中定义了多个stream，根据类型来分组发送给不同类型的SaveDataBolt组件。
        <br/>
        下面看每个组件的实现：
       </p>
       <ul>
        <li>
         ProduceRecordSpout组件
        </li>
       </ul>
       <p>
        通过我们定义的一个ProduceRecordSpout类，可以创建3个不同的ProduceRecordSpout实例，每个实例负责生产特定类型的数据，实现代码如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_948266">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               ProduceRecordSpout
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichSpout {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(ProduceRecordSpout.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               SpoutOutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               Random rand;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               String[] recordLines;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               String type;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="plain">
               ProduceRecordSpout(String type, String[] lines) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .type = type;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               recordLines = lines;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               rand =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Random();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               nextTuple() {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Utils.sleep(
              </code>
              <code class="value">
               500
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String record = recordLines[rand.nextInt(recordLines.length)];
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               List&lt;Object&gt; values =
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Values(type, record);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.emit(values, values);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "Record emitted: type="
              </code>
              <code class="plain">
               + type +
              </code>
              <code class="string">
               ", record="
              </code>
              <code class="plain">
               + record);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               33
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declare(
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "record"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               34
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               35
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        这比较简单，根据传递的参数来创建上图中的3个Spout实例。
       </p>
       <ul>
        <li>
         SplitRecordBolt组件
        </li>
       </ul>
       <p>
        由于前面3个ProduceRecordSpout产生的数据，在开始时的处理逻辑是相同的，所以可以将3个ProduceRecordSpout聚合到一个包含通用逻辑的SplitRecordBolt组件，实现如下所示：
       </p>
       <div class="syntaxhighlighter " id="highlighter_560648">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               SplitRecordBolt
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichBolt {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(SplitRecordBolt.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               OutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               prepare(Map stormConf, TopologyContext context,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               OutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               execute(Tuple input) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String type = input.getString(
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String line = input.getString(
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               if
              </code>
              <code class="plain">
               (line !=
              </code>
              <code class="keyword">
               null
              </code>
              <code class="plain">
               &amp;&amp; !line.trim().isEmpty()) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               for
              </code>
              <code class="plain">
               (String word  : line.split(
              </code>
              <code class="string">
               "\\s+"
              </code>
              <code class="plain">
               )) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.emit(input,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Values(type, word));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "Word emitted: type="
              </code>
              <code class="plain">
               + type +
              </code>
              <code class="string">
               ", word="
              </code>
              <code class="plain">
               + word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // ack tuple
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.ack(input);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declare(
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        无论接收到的Tuple是什么类型（STRING、NUMBER、SIGN）的数据，都进行split，然后在emit的时候，仍然将类型信息传递给下一个Bolt组件。
       </p>
       <ul>
        <li>
         DistributeWordByTypeBolt组件
        </li>
       </ul>
       <p>
        DistributeWordByTypeBolt组件只是用来分发Tuple，通过定义Stream，将接收到的Tuple发送到指定的下游Bolt组件进行处理。通过SplitRecordBolt组件emit的Tuple包含了类型信息，所以在DistributeWordByTypeBolt中根据类型来进行分发，代码实现如下：
       </p>
       <div class="syntaxhighlighter " id="highlighter_543660">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               DistributeWordByTypeBolt
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichBolt {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(DistributeWordByTypeBolt.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               OutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               prepare(Map stormConf, TopologyContext context,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               OutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               Map&lt;GlobalStreamId, Grouping&gt; sources = context.getThisSources();
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "sources==&gt; "
              </code>
              <code class="plain">
               + sources);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               execute(Tuple input) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String type = input.getString(
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               String word = input.getString(
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               switch
              </code>
              <code class="plain">
               (type) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               case
              </code>
              <code class="plain">
               Type.NUMBER:
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               emit(
              </code>
              <code class="string">
               "stream-number-saver"
              </code>
              <code class="plain">
               , type, input, word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               break
              </code>
              <code class="plain">
               ;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               case
              </code>
              <code class="plain">
               Type.STRING:
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               emit(
              </code>
              <code class="string">
               "stream-string-saver"
              </code>
              <code class="plain">
               , type, input, word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               break
              </code>
              <code class="plain">
               ;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               case
              </code>
              <code class="plain">
               Type.SIGN:
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               emit(
              </code>
              <code class="string">
               "stream-sign-saver"
              </code>
              <code class="plain">
               , type, input, word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               break
              </code>
              <code class="plain">
               ;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               default
              </code>
              <code class="plain">
               :
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // if unknown type, record is discarded.
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // as needed, you can define a bolt to subscribe the stream 'stream-discarder'.
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               emit(
              </code>
              <code class="string">
               "stream-discarder"
              </code>
              <code class="plain">
               , type, input, word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               33
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               34
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // ack tuple
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               35
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.ack(input);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               36
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               37
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               38
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               emit(String streamId, String type, Tuple input, String word) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               39
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               collector.emit(streamId, input,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Values(type, word));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               40
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "Distribution, typed word emitted: type="
              </code>
              <code class="plain">
               + type +
              </code>
              <code class="string">
               ", word="
              </code>
              <code class="plain">
               + word);
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               41
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               42
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               43
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               44
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               45
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declareStream(
              </code>
              <code class="string">
               "stream-number-saver"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               46
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declareStream(
              </code>
              <code class="string">
               "stream-string-saver"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               47
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declareStream(
              </code>
              <code class="string">
               "stream-sign-saver"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               48
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               declarer.declareStream(
              </code>
              <code class="string">
               "stream-discarder"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="keyword">
               new
              </code>
              <code class="plain">
               Fields(
              </code>
              <code class="string">
               "type"
              </code>
              <code class="plain">
               ,
              </code>
              <code class="string">
               "word"
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               49
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               50
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        实际上，下游的3个Bolt组件（SaveDataBolt）在订阅该流组件（DistributeWordByTypeBolt）的时候，方式相同，只是分发的逻辑交由DistributeWordByTypeBolt来统一控制。
        <br/>
        我们在配置该Bolt组件时，使用了fieldsGrouping分组方式，实际每个DistributeWordByTypeBolt只会收到同一种类型的Tuple，这里也可以使用shuffleGrouping分组方式，这种分组方式会有不同类型的Tuple被emit到同一个DistributeWordByTypeBolt组件上。
        <br/>
        另外，该Bolt组件中我们还定义了一个名称为stream-discarder的stream，在Topology中并没有满足该stream的条件，可以根据实际情况选择是否实现它。
       </p>
       <ul>
        <li>
         SaveDataBolt组件
        </li>
       </ul>
       <p>
        最后这个Bolt用来模拟保存处理过的数据内容，代码如下：
       </p>
       <div class="syntaxhighlighter " id="highlighter_34883">
        <div class="lines">
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               01
              </code>
             </td>
             <td class="content">
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               SaveDataBolt
              </code>
              <code class="keyword">
               extends
              </code>
              <code class="plain">
               BaseRichBolt {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               02
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               03
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="keyword">
               long
              </code>
              <code class="plain">
               serialVersionUID = 1L;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               04
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="keyword">
               static
              </code>
              <code class="keyword">
               final
              </code>
              <code class="plain">
               Log LOG = LogFactory.getLog(SaveDataBolt.
              </code>
              <code class="keyword">
               class
              </code>
              <code class="plain">
               );
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               05
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               OutputCollector collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               06
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               07
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               private
              </code>
              <code class="plain">
               String type;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               08
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               09
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="plain">
               SaveDataBolt(String type) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               10
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .type = type;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               11
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               12
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               13
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               14
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               prepare(Map stormConf, TopologyContext context,
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               15
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               OutputCollector collector) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               16
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               this
              </code>
              <code class="plain">
               .collector = collector;
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               17
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               18
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               19
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               20
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               execute(Tuple input) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               21
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // just print the received tuple for being waited to persist
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               22
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               LOG.info(
              </code>
              <code class="string">
               "["
              </code>
              <code class="plain">
               + type +
              </code>
              <code class="string">
               "] "
              </code>
              <code class="plain">
               +
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               23
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               "SourceComponent="
              </code>
              <code class="plain">
               + input.getSourceComponent() +
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               24
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               ", SourceStreamId="
              </code>
              <code class="plain">
               + input.getSourceStreamId() +
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               25
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               ", type="
              </code>
              <code class="plain">
               + input.getString(
              </code>
              <code class="value">
               0
              </code>
              <code class="plain">
               ) +
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               26
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="string">
               ", value="
              </code>
              <code class="plain">
               + input.getString(
              </code>
              <code class="value">
               1
              </code>
              <code class="plain">
               ));
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               27
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               28
              </code>
             </td>
             <td class="content">
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               29
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="color1">
               @Override
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               30
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="keyword">
               public
              </code>
              <code class="keyword">
               void
              </code>
              <code class="plain">
               declareOutputFields(OutputFieldsDeclarer declarer) {
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               31
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="comments">
               // do nothing
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               32
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt1">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               33
              </code>
             </td>
             <td class="content">
              <code class="spaces">
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
         <div class="line alt2">
          <table>
           <tbody>
            <tr>
             <td class="number">
              <code>
               34
              </code>
             </td>
             <td class="content">
              <code class="plain">
               }
              </code>
             </td>
            </tr>
           </tbody>
          </table>
         </div>
        </div>
       </div>
       <p>
        在实际应用中，你可能需要将处理过的数据保存到数据库中，就可以在该Bolt中实现存储数据的逻辑。
       </p>
       <p>
        <strong>
         总结
        </strong>
       </p>
       <p>
        Storm中最核心的计算组件的抽象就是Spout、Bolt，以及Stream Grouping，其它高级的功能，像Trident、DRPC，他们或者基于这些基础组件以及Streaming Grouping分发策略来实现的，屏蔽了底层的分发计算处理逻辑以更高层的编程抽象面向开发者，减轻了开发人员对底层复杂机制的处理；或者是为了方便使用Storm计算服务而增加的计算机制衍生物，如批量事务处理、RPC等。
       </p>
       <p>
        <strong>
         参考链接
        </strong>
       </p>
       <ul>
        <li>
         <a href="http://storm.apache.org/documentation/Documentation.html" target="_blank">
          http://storm.apache.org/documentation/Documentation.html
         </a>
        </li>
        <li>
         <a href="http://storm.apache.org/documentation/Concepts.html" target="_blank">
          http://storm.apache.org/documentation/Concepts.html
         </a>
        </li>
        <li>
         <a href="http://storm.apache.org/documentation/Tutorial.html" target="_blank">
          http://storm.apache.org/documentation/Tutorial.html
         </a>
        </li>
        <li>
         <a href="http://storm.apache.org/documentation/Understanding-the-parallelism-of-a-Storm-topology.html" target="_blank">
          http://storm.apache.org/documentation/Understanding-the-parallelism-of-a-Storm-topology.html
         </a>
        </li>
       </ul>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/24220.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/05/100910rrxp5plglxk4lcle-291x200.png"/>
        </a>
        <a class="link" href="http://dataunion.org/24220.html" rel="bookmark" title="520大数据：八成男性期待被表白 “套路”也是爱">
         520大数据：八成男性期待被表白 “套路”也是爱
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/23785.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/04/u7145986293872240263fm21gp0-298x200.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/23785.html" rel="bookmark" title="Docker安全基准：22项新增要点概述">
         Docker安全基准：22项新增要点概述
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/23703.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/04/1317020-300x163.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/23703.html" rel="bookmark" title="推荐：五个不容错过的数据科学家博客">
         推荐：五个不容错过的数据科学家博客
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/23507.html">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/110606wjpugdldig4idddn.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/23507.html" rel="bookmark" title="解密深度学习在智能推荐系统的实践与应用">
         解密深度学习在智能推荐系统的实践与应用
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F16209.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/16209.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/16209.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>